package com.example.supermarket.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class HomeController {
    @RequestMapping("/index")
    public String index() {
        return "index";
    }

    @RequestMapping(value = {"/", "/login"})
    public String login(HttpSession session) {
        Object loginUser = session.getAttribute("user");
        if (loginUser != null)
            return "index";
        return "login";
    }

    @RequestMapping("/customer")
    public String customer() {
        return "customer";
    }

    @RequestMapping("/goods")
    public String goods() {
        return "goods";
    }

    @RequestMapping("/purchase")
    public String purchase() {
        return "purchase";
    }


    @RequestMapping("/dashboard")
    public String dashboard() {
        return "dashboard";
    }


    @RequestMapping("/employee")
    public String employee() {
        return "employee";
    }

    @RequestMapping("/purchaseDetail")
    public String purchaseDetail(int Pid, ModelMap map) {
        map.put("Pid",Pid);
        return "purchaseDetail";
    }

    @RequestMapping("/employeeStatistics")
    public String employeeStatistics() {
        return "employeeStatistics";
    }

    @RequestMapping("/goodsStatistics")
    public String goodsStatistics() {
        return "goodsStatistics";
    }

    @RequestMapping("/purchaseStatistics")
    public String purchaseStatistics() {
        return "purchaseStatistics";
    }
}
